<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
	content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<script src="${pageContext.request.contextPath}/js/echarts.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery-2.min.js"></script>
<link href="${pageContext.request.contextPath}/css/mui.min.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/css/corporeity.css" rel="stylesheet"/>
<style>
 	.main{
 		text-align:center;
 	}
 	.button{
 	    background-color: #AAAAAA; /* Green */
 	    margin-top:20px;
    	border: 1px solid #AAAAAA;
    	color: white;
    	padding: 15px 32px;
    	margin-left:5px;
   	 	text-decoration: none;
   		display: inline-block;
   		font-size: 16px;
    	cursor: pointer;
    	boder-radius:5px;
 	}
 	.warn{
 		margin-left:15px;
 		color:deepskyblue;
 	}
 	#solution{
 	   margin-left:100px;
 	   font-size:20px;
 	}
  .div{
		background-image: url(${pageContext.request.contextPath}/img/aa.jpg); 
		background-repeat: no-repeat; 
		background-size:100% 100%;
		-moz-background-size:100% 100%;
		}  
</style>
<title></title>
</head>
<body class="div">
    <h3 class="warn">您拥有如下体质:</h3>
	<div id="main" class="main" style="width: 370px; height: 100px;"></div>
	<span id="solution"></span>
	<div class="mui-content-padded">
	<div class="left"  align="center" id="corTongingSolution">
			<div class="cor" align="center">
				<div id="corsapn1" class="corspan" align="left">
				</div>
				<div id="corsapn2" class="corspan" align="left">
				</div>
				<div id="btnGroup"></div>
				<div id="corsapn3" class="corspan" align="left">
				</div>
			</div>
		</div>
	<!-- <button id='submitBtn' class="mui-btn mui-btn-block mui-btn-primary" onclick="ShowCorSolutions()" >点击查看更多体质调理方案</button> -->
	</div>
	<input type="hidden" id="cor">
	<div>
	</div>
	<script type="text/javascript">
	var consumer_HistoryCacheId ="009e5376161c41fe826153a563ae6351";     //'${param.Consumer_HistoryCacheId}';
	$(function(){
		$.ajax({
			type : "post",
			url : "${pageContext.request.contextPath}/Consumer/ShowConsumerTestResult.do",
			data:{Consumer_HistoryCacheId:consumer_HistoryCacheId},
			dataType:"json",
			success:function(result){
			if(result.errorMessage=='success'){
				var cmap = result.data.cmap;
				var cmapkey = new Array();
				var cmapvalue = new Array();
				var divMain = $("#main");
				var solution =$("#solution");
				var i=0;
				var btn ="button";
				for(var key in cmap){
					if(i<=2){
						btn = btn+i;
						var button = $("<button id=\"" + btn + "\" class='button' onclick='getToningSolution(\"" + key + "\",\"" + btn + "\")'>"+key+"</button>");
						divMain.append(button);
						getOne(key,i,btn);	
					}
					i++;
				}
				
			}
		}		
		})
		
		makeGroupBtn();
	})
	    //此方法是先执行一次查询
	    function getOne(cor,num,btn){
			if(num==0){
				getToningSolution(cor,btn);	
			}
	    }
	 
	    function getToningSolution(cor,btn){
	  	
	    	threeBtn(btn)
			var solution =$("#solution");
			var warnStr = "<span style = 'color:red;'>"+cor+"</span>" + "的调理方案";
			solution.html(warnStr);
	    	$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/ShowToningSolution.do",
				data:{corporeity:cor},
				dataType:"json",
				success:function(data){
					var cordate = data[0];
					var corperformance = cordate.performance;
					var cortendency = cordate.tendency;
					var cortoning_solution = cordate.toningSolutions;
					$("#corsapn1").html(corperformance);
					$("#corsapn2").html(cortendency);
					//makeGroupBtn();
					$("#corsapn3").html(cortoning_solution);
				}
			})
	    } 
		
	    
	    function makeGroupBtn(){
	    	$.ajax({
	    		type:"get",
	    		url:"${pageContext.request.contextPath}/getDoctorList.do",
	    		success:function(data){
	    			var date =data;
	    			var btnDiv = $("#btnGroup");
	    	    	for(var i=0;i<date.length;i++){
	    	    		var btnValue = date[i].doctor;
	    	    		var uuid = date[i].uuid;
	    	    		var btn = $("<button id=\"" + i + "\" class='button' onclick='getCorTonSolution(\"" + uuid + "\")'>"+btnValue+"</button>");
	    	    		btnDiv.append(btn);
	    	    	}
	    		}
	    	})
	    }
	    
	    
	    function getCorTonSolution(uuid){
	    	
	    }
	  /*   function makeGroupBtn(){
	    	var btnDiv = $("#btnGroup");
	    	for(var i=0;i<3;i++){
	    		var btn = $("<button id=\"" + i + "\">张三"+i+"</button>");
	    		btnDiv.append(btn);
	    	}
	    } */
	    
	    function threeBtn(btn){
	    	if(btn == "button0"){
	    		$("#button0").css("opacity", "0.6");
	    		$("#button0").attr("disabled","disabled");
	    		$("#button01").css("opacity", "");
	    		$("#button01").removeAttr("disabled");
	    		$("#button012").css("opacity", "");
	    		$("#button012").removeAttr("disabled");
	    	}else if(btn == "button01"){
	    		$("#button0").css("opacity", "");
	    		$("#button0").removeAttr("disabled");
	    		$("#button012").css("opacity", "");
	    		$("#button012").removeAttr("disabled");
	    		$("#button01").css("opacity", "0.6");
	    		$("#button01").attr("disabled","disabled");
	    	}else if(btn =="button012"){
	    		$("#button0").css("opacity", "");
	    		$("#button0").removeAttr("disabled");
	    		$("#button01").css("opacity", "");
	    		$("#button01").removeAttr("disabled");
	    		$("#button012").css("opacity", "0.6");
	    		$("#button012").attr("disabled","disabled");
	    	}
	    	
	    }
		function ShowCorSolutions(){
/* 				var cor = $("#cor").val();
			    var form = $("<form></form>");  
			    form.attr('action', "${pageContext.request.contextPath}/ShowCorSolutions.jsp");  
			    form.attr('method', 'post');  
			    form.attr('target', '_self');  
			    var input1 = $("<input type='hidden' name='cor' />");  
			    input1.attr('value',cor);  
			    form.append(input1);  
			    form.appendTo("body");  
			    form.css('display', 'none');  
			    form.submit();   */
			window.location.href="https://mp.weixin.qq.com/s/VkrW_ArKT9aqiZoHkcD-QA?backurl="+window.location.href; 
		};
	</script>
</body>
</html>
